{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "434a61b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0fc477e4",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7841ffa3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4071241c",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('dataset/Advertising.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9c38963d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>TV</th>\n",
       "      <th>radio</th>\n",
       "      <th>newspaper</th>\n",
       "      <th>sales</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>230.1</td>\n",
       "      <td>37.8</td>\n",
       "      <td>69.2</td>\n",
       "      <td>22.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>44.5</td>\n",
       "      <td>39.3</td>\n",
       "      <td>45.1</td>\n",
       "      <td>10.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>17.2</td>\n",
       "      <td>45.9</td>\n",
       "      <td>69.3</td>\n",
       "      <td>9.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>151.5</td>\n",
       "      <td>41.3</td>\n",
       "      <td>58.5</td>\n",
       "      <td>18.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>180.8</td>\n",
       "      <td>10.8</td>\n",
       "      <td>58.4</td>\n",
       "      <td>12.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0     TV  radio  newspaper  sales\n",
       "0           1  230.1   37.8       69.2   22.1\n",
       "1           2   44.5   39.3       45.1   10.4\n",
       "2           3   17.2   45.9       69.3    9.3\n",
       "3           4  151.5   41.3       58.5   18.5\n",
       "4           5  180.8   10.8       58.4   12.9"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "e1ed5ce7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x25a5e999908>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAj1UlEQVR4nO2dfYwd13nen5fLFbOUBS0VEQK1FkU6MERYTq2VFqkKGkYoJ1YsxRYdpY6NJFVQowRaB4hUlyjdGBXtovDWqm20a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bwEPq3rovo++w+ZrIf/ZX3/x6dq2MAJtq232IsfxrZ+mz0I9oy8Po/jMZyAsD727Y/ZTzvRt898iyAI9G/W0I8PxljCfL8APhHAGYju58D8O+j7W9D/0LzIoCHAWyItv9c9PeL0fNvs9kPU+kJISRQfHehEEIIMUABJ4SQQKGAE0JIoFDACSEkUCjghBASKBRwQggJFAo4IYQEyv8Hcallv9F16RwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 查看线性关系\n",
    "plt.scatter(data.TV, data.sales)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "878f1713",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x25a60f32cc8>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAAi1UlEQVR4nO2df5BdZXnHv89uLrIB6waJmbgSk06dZMCU7LCjdOIfJK1EDcIKFsqgQ0en+Uc7ktKtq39AqDpspTU6Y6fTWBhxSmmQYAzGKTKQlpqp2I2bAJEwWgFxRbIOLCJZ4Wb36R/33uTuuef3ec8573vO9zOTye7Zu3vec+97nvO83/f7Pq+oKgghhLhHX9kNIIQQkg4GcEIIcRQGcEIIcRQGcEIIcRQGcEIIcZQlRZ7s3HPP1dWrVxd5SkIIcZ5Dhw79WlWXe48XGsBXr16NycnJIk9JCCHOIyLP+h2nhEIIIY7CAE4IIY7CAE4IIY7CAE4IIY7CAE4IIY5SqAuFEEKqzN6padz2wFP45ewc3j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TCA4wAeBPB/AGZV9WT7JVXs518G8DcAFtrfvxnVv2YF8D0ROSQi29rHjPVv7sjjCKqqIlJJz6eInA1gD4AbVPU3rcSsRVWvW1XnAWwQkUEA3wKwrtwW5YuIXAbguKoeEpFLSm5OkbxHVadF5C0AHhSRY90/zNq/XcjApwGc1/X929rH6sALIrISANr/Hy+5PcYRkQZawfsuVb2vfbjy191BVWcBHADwRwAGRaSTVFWtn28EcLmIPIOWDLoZwFdQ7WuGqk63/z+O1oP6XTDYv10I4P8L4B3t2eozAPwZgH0lt6ko9gG4vv319QC+XWJbjNPWQG8H8KSqfqnrR1W/7uXtzBsiMgDgvWjp/wcAfLj9skpdt6p+RlXfpqqr0bqHH1bV61DhaxaRs0TkjZ2vAVwK4AkY7N9OrMQUkQ+gpZ/1A7hDVb9QbovMIyJ3A7gErVKTLwC4GcBeAPcAWIVWGd6rVdU70eksIvIeAP8N4HGc1kU/i5YOXuXr/kO0Jq/60Uqi7lHVvxWR30crOz0HwBSAj6jqa+W1NB/aEspfq+plVb7m9rV9q/3tEgD/pqpfEJE3w1D/diKAE0II6cUFCYUQQogPDOCEEOIoDOCEEOIoDOCEEOIoDOCEEOIoDOCEEOIoDOCEEOIo/w8ziIwKS4zCBQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(data.radio, data.sales)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5bc6371c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x25a60fb7448>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuM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B8GMD/AfA3AP5t2+0peQ7/CP1Hum8DODz492H0/eInAHwXwF8BuKDttlY4xw8A+Nrg578H4K8BfA/AnwI4u+32FTyXrQDmB9drDsD6LlwrAJ8BcBTAswD+GMDZIV4rAA+h7+Mvo//E9AnT9QEg6Gey/Q2AI+hn4bR+Dq7+cSo9IYQEiu8WCiGEEAMUcEIICRQKOCGEBAoFnBBCAoUCTgghgUIBJ4SQQKGAE0JIoPx/WpR66BTAR70AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(data.newspaper, data.sales)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "6ea55fa1",
   "metadata": {},
   "outputs": [],
   "source": [
    "x = data.iloc[:,1:-1]\n",
    "y = data.iloc[:,-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e4fc8399",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Dense参数越大拟合能力越强 3维数据 输出维度为1\n",
    "model = tf.keras.Sequential([tf.keras.layers.Dense(10, input_shape=(3,),activation='relu'),\n",
    "                             tf.keras.layers.Dense(1)]\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "899e83bb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense (Dense)                (None, 10)                40        \n",
      "_________________________________________________________________\n",
      "dense_1 (Dense)              (None, 1)                 11        \n",
      "=================================================================\n",
      "Total params: 51\n",
      "Trainable params: 51\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.summary()\n",
    "# 中间层10个隐藏单元 40个参数(每个单元3个权重1个 偏置)\n",
    "# dense_1为输出层"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "aac05243",
   "metadata": {},
   "outputs": [],
   "source": [
    "model.compile(optimizer='adam',\n",
    "              loss='mse'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "244b6d0a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 1/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 2274.4954\n",
      "Epoch 2/100\n",
      "7/7 [==============================] - 0s 657us/step - loss: 1978.3755\n",
      "Epoch 3/100\n",
      "7/7 [==============================] - 0s 959us/step - loss: 1699.6614\n",
      "Epoch 4/100\n",
      "7/7 [==============================] - 0s 750us/step - loss: 1465.1622\n",
      "Epoch 5/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 1249.9755\n",
      "Epoch 6/100\n",
      "7/7 [==============================] - 0s 658us/step - loss: 1065.1228\n",
      "Epoch 7/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 898.5472\n",
      "Epoch 8/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 764.6038\n",
      "Epoch 9/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 646.2633\n",
      "Epoch 10/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 553.1682\n",
      "Epoch 11/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 468.7909\n",
      "Epoch 12/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 399.4428\n",
      "Epoch 13/100\n",
      "7/7 [==============================] - 0s 864us/step - loss: 343.4760\n",
      "Epoch 14/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 292.3764\n",
      "Epoch 15/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 252.7815\n",
      "Epoch 16/100\n",
      "7/7 [==============================] - 0s 712us/step - loss: 216.9986\n",
      "Epoch 17/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 189.6629\n",
      "Epoch 18/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 167.1899\n",
      "Epoch 19/100\n",
      "7/7 [==============================] - 0s 834us/step - loss: 147.6623\n",
      "Epoch 20/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 132.3660\n",
      "Epoch 21/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 119.1026\n",
      "Epoch 22/100\n",
      "7/7 [==============================] - 0s 997us/step - loss: 108.2693\n",
      "Epoch 23/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 99.6791\n",
      "Epoch 24/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 92.2437\n",
      "Epoch 25/100\n",
      "7/7 [==============================] - 0s 664us/step - loss: 86.0254\n",
      "Epoch 26/100\n",
      "7/7 [==============================] - 0s 855us/step - loss: 80.6745\n",
      "Epoch 27/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 76.6336\n",
      "Epoch 28/100\n",
      "7/7 [==============================] - 0s 773us/step - loss: 73.1990\n",
      "Epoch 29/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 70.5225\n",
      "Epoch 30/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 68.4072\n",
      "Epoch 31/100\n",
      "7/7 [==============================] - 0s 790us/step - loss: 66.5698\n",
      "Epoch 32/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 65.1178\n",
      "Epoch 33/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 63.7020\n",
      "Epoch 34/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 62.6134\n",
      "Epoch 35/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 61.5972\n",
      "Epoch 36/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 60.7140\n",
      "Epoch 37/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 59.8972\n",
      "Epoch 38/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 59.0701\n",
      "Epoch 39/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 58.1835\n",
      "Epoch 40/100\n",
      "7/7 [==============================] - 0s 883us/step - loss: 57.3980\n",
      "Epoch 41/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 56.5345\n",
      "Epoch 42/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 55.7390\n",
      "Epoch 43/100\n",
      "7/7 [==============================] - 0s 766us/step - loss: 54.9240\n",
      "Epoch 44/100\n",
      "7/7 [==============================] - 0s 879us/step - loss: 54.1773\n",
      "Epoch 45/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 53.4643\n",
      "Epoch 46/100\n",
      "7/7 [==============================] - 0s 885us/step - loss: 52.7268\n",
      "Epoch 47/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 52.0599\n",
      "Epoch 48/100\n",
      "7/7 [==============================] - 0s 997us/step - loss: 51.3902\n",
      "Epoch 49/100\n",
      "7/7 [==============================] - 0s 855us/step - loss: 50.6889\n",
      "Epoch 50/100\n",
      "7/7 [==============================] - 0s 861us/step - loss: 50.0405\n",
      "Epoch 51/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 49.3088\n",
      "Epoch 52/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 48.5966\n",
      "Epoch 53/100\n",
      "7/7 [==============================] - 0s 526us/step - loss: 47.9035\n",
      "Epoch 54/100\n",
      "7/7 [==============================] - 0s 826us/step - loss: 47.1871\n",
      "Epoch 55/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 46.4903\n",
      "Epoch 56/100\n",
      "7/7 [==============================] - 0s 715us/step - loss: 45.7994\n",
      "Epoch 57/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 45.0993\n",
      "Epoch 58/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 44.4791\n",
      "Epoch 59/100\n",
      "7/7 [==============================] - 0s 722us/step - loss: 43.7846\n",
      "Epoch 60/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 43.1222\n",
      "Epoch 61/100\n",
      "7/7 [==============================] - 0s 996us/step - loss: 42.4379\n",
      "Epoch 62/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 41.7489\n",
      "Epoch 63/100\n",
      "7/7 [==============================] - 0s 2ms/step - loss: 40.9789\n",
      "Epoch 64/100\n",
      "7/7 [==============================] - 0s 727us/step - loss: 40.3660\n",
      "Epoch 65/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 39.6564\n",
      "Epoch 66/100\n",
      "7/7 [==============================] - 0s 990us/step - loss: 39.0660\n",
      "Epoch 67/100\n",
      "7/7 [==============================] - 0s 712us/step - loss: 38.4093\n",
      "Epoch 68/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 37.8057\n",
      "Epoch 69/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 37.1503\n",
      "Epoch 70/100\n",
      "7/7 [==============================] - 0s 712us/step - loss: 36.4936\n",
      "Epoch 71/100\n",
      "7/7 [==============================] - 0s 710us/step - loss: 35.6940\n",
      "Epoch 72/100\n",
      "7/7 [==============================] - 0s 774us/step - loss: 34.9598\n",
      "Epoch 73/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 34.1424\n",
      "Epoch 74/100\n",
      "7/7 [==============================] - 0s 719us/step - loss: 33.2019\n",
      "Epoch 75/100\n",
      "7/7 [==============================] - 0s 855us/step - loss: 32.3875\n",
      "Epoch 76/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 31.6060\n",
      "Epoch 77/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 30.9467\n",
      "Epoch 78/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 30.3194\n",
      "Epoch 79/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 29.6877\n",
      "Epoch 80/100\n",
      "7/7 [==============================] - 0s 706us/step - loss: 29.1373\n",
      "Epoch 81/100\n",
      "7/7 [==============================] - 0s 855us/step - loss: 28.5678\n",
      "Epoch 82/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 27.8763\n",
      "Epoch 83/100\n",
      "7/7 [==============================] - 0s 853us/step - loss: 27.2644\n",
      "Epoch 84/100\n",
      "7/7 [==============================] - 0s 714us/step - loss: 26.4837\n",
      "Epoch 85/100\n",
      "7/7 [==============================] - 0s 912us/step - loss: 25.7097\n",
      "Epoch 86/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 25.0159\n",
      "Epoch 87/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 24.2981\n",
      "Epoch 88/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 23.7806\n",
      "Epoch 89/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 23.1623\n",
      "Epoch 90/100\n",
      "7/7 [==============================] - 0s 709us/step - loss: 22.6627\n",
      "Epoch 91/100\n",
      "7/7 [==============================] - 0s 760us/step - loss: 22.1807\n",
      "Epoch 92/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 21.7267\n",
      "Epoch 93/100\n",
      "7/7 [==============================] - 0s 897us/step - loss: 21.2695\n",
      "Epoch 94/100\n",
      "7/7 [==============================] - 0s 843us/step - loss: 20.8694\n",
      "Epoch 95/100\n",
      "7/7 [==============================] - 0s 855us/step - loss: 20.4292\n",
      "Epoch 96/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 19.9993\n",
      "Epoch 97/100\n",
      "7/7 [==============================] - 0s 570us/step - loss: 19.6256\n",
      "Epoch 98/100\n",
      "7/7 [==============================] - 0s 847us/step - loss: 19.2211\n",
      "Epoch 99/100\n",
      "7/7 [==============================] - 0s 917us/step - loss: 18.8220\n",
      "Epoch 100/100\n",
      "7/7 [==============================] - 0s 1ms/step - loss: 18.4351\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<tensorflow.python.keras.callbacks.History at 0x25a614c1d88>"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.fit(x, y, epochs=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "df10b4ae",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 预测前10个数据\n",
    "test = data.iloc[:10, 1:-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "77481c99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[28.474653 ],\n",
       "       [12.564444 ],\n",
       "       [ 3.698114 ],\n",
       "       [26.036943 ],\n",
       "       [17.633509 ],\n",
       "       [ 1.9398183],\n",
       "       [12.973489 ],\n",
       "       [10.488782 ],\n",
       "       [ 1.1518904],\n",
       "       [ 8.784375 ]], dtype=float32)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.predict(test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "144dcd95",
   "metadata": {},
   "outputs": [],
   "source": [
    "test = data.iloc[:10, -1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "015421b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    22.1\n",
       "1    10.4\n",
       "2     9.3\n",
       "3    18.5\n",
       "4    12.9\n",
       "5     7.2\n",
       "6    11.8\n",
       "7    13.2\n",
       "8     4.8\n",
       "9    10.6\n",
       "Name: sales, dtype: float64"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c8b9e013",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
